package com.ktgj.file.api;

import com.ktgj.common.core.constant.ServiceNameConstants;
import com.ktgj.common.core.domain.R;
import com.ktgj.file.api.domain.SysFileApi;
import com.ktgj.file.api.factory.RemoteFilesFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.Map;

/**
 * 文件服务
 */
@FeignClient(contextId = "RemoteFilesService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFilesFallbackFactory.class)
public interface RemoteFilesService {
    /**
     * 航司LogoUrl
     * */
    @PostMapping("/fileMapping/airlineLogo")
    public String airlineLogo();

    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<SysFileApi> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 上传文件到服务器
     * @param file 文件流
     * @return
     */
    @PostMapping("/fileMapping/document")
    public File document(MultipartFile file);
}
